<meta charset="UTF-8">
<?php
include_once("../functions/db_manipulate.php");

if (!init()) {
    redirect("../login.php");
}
if (isset($_GET['galid'])) {

    connectDB();
    startTransaction();

    $resultSet = mysql_query("DELETE FROM gallery WHERE userid='" . $_SESSION['id'] . "' AND id='" . $_GET['galid'] . "'") or die(mysql_error());
    if ($resultSet) {
        commitTransaction();
    } else {
        rollbackTransaction();
    }
}

redirect($_SERVER['HTTP_REFERER']);